package com.zcxy.fast.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zcxy.fast.anotation.Log;
import com.zcxy.fast.bean.PageQuery;
import com.zcxy.fast.bean.Response;
import com.zcxy.fast.entity.SysComponet;
import com.zcxy.fast.vo.SysComponetVo;
import com.zcxy.fast.service.ISysComponetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.*;
import com.zcxy.fast.bean.TreeNode;

/**
 * vue组件数据配置Controller
 *
 * @author zcc
 * @email  860474958@qq.com
 * @date   2021-01-15 07:40:36
 */
@RestController
@RequestMapping("/api/sysComponet")
@Api(tags = "vue组件数据配置管理")
@Slf4j
public class SysComponetController {
    @Autowired
    private ISysComponetService iSysComponetService;

    @Log("获取vue组件数据配置数据--分页")
    @PostMapping(value = "/queryPageList")
    @ApiOperation(value = "获取(vue组件数据配置)分页数据列表", notes = "获取(vue组件数据配置)分页数据列表")
    public Response<IPage<SysComponetVo>> queryPageList(@RequestBody PageQuery<SysComponet> queryVo) {
        return Response.ok(iSysComponetService.queryPageList(queryVo));
    }

    @Log("获取vue组件数据配置数据-列表")
    @PostMapping(value = "/queryList")
    @ApiOperation(value = "获取vue组件数据配置数据-列表", notes = "获取vue组件数据配置数据-列表")
    public Response<List<SysComponetVo>> queryList(@RequestBody SysComponet sysComponet) {
        return Response.ok(iSysComponetService.queryList( sysComponet));
    }


    @Log("添加vue组件数据配置数据")
    @PostMapping(value = "/add")
    @ApiOperation(value = "添加vue组件数据配置数据", notes = "添加vue组件数据配置数据")
    public Response addSysComponet(@RequestBody @Validated @NotNull SysComponet queryVo) {
        iSysComponetService.addSysComponet(queryVo);
        return Response.ok();
    }


    @Log("修改vue组件数据配置数据")
    @PostMapping(value = "/update")
    @ApiOperation(value = "修改vue组件数据配置数据", notes = "修改vue组件数据配置数据")
    public Response updateSysComponet(@RequestBody @Validated @NotNull SysComponet queryVo) {
        iSysComponetService.updateSysComponet(queryVo);
        return Response.ok();
    }


    @Log(value = "批量删除vue组件数据配置")
    @ApiOperation("批量删除vue组件数据配置")
    @PostMapping("/dels")
    public Response deleteByIds(@RequestBody List<String> ids) {
        iSysComponetService.removeAllSysComponet(ids);
        return Response.ok();
    }


    @Log(value = "通过代码查看")
    @ApiOperation("通过代码查看")
    @GetMapping("/viewByCode")
    public Response<SysComponet> viewByCode(@RequestParam String code) {
        return Response.ok(iSysComponetService.viewSysComponet(code));
    }






}
